package com.xt.base.dao.hibernate;

import org.hibernate.SessionFactory;

import com.xt.base.exception.SystemError;

public class SessionFactoryHolder {

	private SessionFactory sessionFactory;

	private static final org.apache.log4j.Logger log = org.apache.log4j.Logger
			.getLogger(SessionFactoryHolder.class);

	private static SessionFactoryHolder instance;

	private SessionFactoryHolder() {
		instance = this;
		log.warn("new instance of HiberSessionFactoryHolder");
	}

	public static SessionFactoryHolder getInstance() {
		if (instance == null)
			throw new SystemError("SessionFactoryHolder", null,
					"HiberSessionFactoryHolder hasnot instanced.");
		return instance;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}
}
